package cn.easybuy.service.impl;

import cn.easybuy.dao.OrderDAO;
import cn.easybuy.dao.impl.OrderDAOImpl;
import cn.easybuy.entity.Order;
import cn.easybuy.entity.OrderDetail;
import cn.easybuy.entity.OrderShow;
import cn.easybuy.entity.UserAddress;
import cn.easybuy.service.OrderService;
import com.sun.org.apache.xpath.internal.operations.Or;

import java.sql.SQLException;
import java.util.List;

public class OrderServiceImpl implements OrderService {
    private OrderDAO orderDAO = new OrderDAOImpl();
    @Override
    public List<Order> SelOrder(int id) throws SQLException {
        return orderDAO.SelOrder(id);
    }

    @Override
    public List<OrderShow> SelOrderPar(String serialNumber) throws SQLException {
        return orderDAO.SelOrderPar(serialNumber);
    }

    @Override
    public List<UserAddress> SelUserAddress(int id) throws SQLException {
        return orderDAO.SelUserAddress(id);
    }

    @Override
    public boolean AddUserAddress(UserAddress userAddress) throws SQLException {
        int i = orderDAO.AddUserAddress(userAddress);
        if (i>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean AddOrder(Order order) throws SQLException {
        int i = orderDAO.AddOrder(order);
        if (i>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public int selOrder(String serialNumber) throws SQLException {
        return orderDAO.selOrder(serialNumber);
    }

    @Override
    public boolean AddDatail(OrderDetail orderDetail) throws SQLException {
        int i = orderDAO.AddDatail(orderDetail);
        if (i>0){
            return true;
        }else {
            return false;
        }
    }
}
